<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title></title>
	<style type="text/css">
		div{
			
			margin-bottom: 15px;
		}
		#main{
		
			margin-top: 200px;
			
			
		}
		h2{
			text-align: center;
		}
		.button{
			width: 88px;
			height: 40px;
			margin: 15px;
		}
		
	</style>
</head>
<body style="text-align: center;">
	<?php
	include_once("conn.php");
	$intx=$_GET['class'];
	$inty=$_GET['kemu'];
	?>
	<div id="main">
		<h2>添加考试</h2>
		<form method="post" action="" name="form1" onsubmit="return dataForm()">
			<div>考试班级：<input type="text" name="clss" id="" value='<?php echo $intx?>' /></div>
			<div>考试课程：<input type="text" name="kemu" id="" value='<?php echo $inty?>' /></div>
			<div>考试时间：<input type="datetime-local" name="time" id="" value="" /></div>
			<div>考试地点：<input type="text" name="didian" id="" value="" /></div>
			<div>监考老师：<input type="text" name="teacher" id="" value="" /></div>
			<div>
				<input class="button" type="submit" name="subr" id="" value="提交" />
				<input class="button" type="reset" name="" id="" value="重新编辑" />
			</div>
			
		</form>
		<div style="margin-top: 100px;text-align: center;"><img src="img/福州大学至诚学院8字.png" width="50%"/></div>
	</div>
</body>
<script>
	function dataForm(){
		var getclass = document.form1.clss.value;
		var getkemu = document.form1.kemu.value;
		var gettime = document.form1.time.value;
		var getdidian = document.form1.didian.value;
		var getteacher = document.form1.teacher.value;
		if(getclass.length==0){window.alert("班级不能为空");return false;}
		if(getkemu.length==0){window.alert("课程不能为空");return false;}
		if(gettime.length==0){window.alert("时间不能为空");return false;}
		if(getdidian.length==0){window.alert("地点不能为空");return false;}
		if(getteacher.length==0){window.alert("监考老师不能为空");return false;}
	}
</script>

<?php
if(isset($_POST["subr"])){
$clss=$_POST['clss'];
$kemu=$_POST['kemu'];
$time=$_POST['time'];
$didian=$_POST['didian'];
$teacher=$_POST['teacher'];
$result=mysqli_query($conn,"UPDATE text SET didian='$didian' WHERE class='$intx' and kemu='$inty' ");
$result=mysqli_query($conn,"UPDATE text SET time='$time' WHERE class='$intx' and kemu='$inty' ");
$result=mysqli_query($conn,"UPDATE text SET teather='$teacher' WHERE class='$intx' and kemu='$inty' ");
header("Location:tianjiasucc.php");
}
?>
</html>